//
//  PageCell.swift
//  VO_Yuejie
//
//  Created by laichunhui on 15/11/27.
//  Copyright © 2015年 lch. All rights reserved.
//

import UIKit

class PageCell: UICollectionViewCell {
    /// 图片高度约束
    @IBOutlet weak var pictureHeightCons: NSLayoutConstraint!
    
    @IBOutlet weak var pictureView: UIImageView!
    
    @IBOutlet weak var titleLabel: UILabel!
    
    @IBOutlet weak var shortContentLabel: UILabel!
    
    @IBOutlet weak var shortContentView: UIView!
    
    @IBOutlet weak var indexLabel: UILabel!
    
    var viewModel: PageViewModel? {
        didSet {
            pictureView.vo_setImageWithURL((viewModel?.image_url)!, placeholderImage: UIImage(named: "sm_big_topic_default")!)
            
            titleLabel.text = viewModel?.title
            shortContentView.hidden =  viewModel?.short_content == ""
   
            if let contentText = viewModel?.short_content {
                     shortContentLabel.text = contentText
            }
            
            layoutIfNeeded()
        }
    }

    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
    
    override func layoutSubviews() {
       
       
        super.layoutSubviews()
        
         pictureHeightCons.constant = (viewModel?.pictureHeight)!
        
      //  pictureView.height = (viewModel?.pictureHeight)!
        
        
    }
    

}
